using UnityEngine;
using System.Collections;

public class LandMine : MonoBehaviour {

	public float detTimer = 1f;
	public float explosionRadius = 5f;
	public float damage = 10f;

	bool triggered=false;

	void Update () {
		if(triggered == true) {
			detTimer -= Time.deltaTime;

			if(detTimer <= 0) {
				GameObject.FindObjectOfType<GameManager>().DoSplashDamage(
					transform.position, 
					explosionRadius * GameManager.Instance.landMineEffectiveness * GameManager.Instance.bulletBonusDamagePerc, 
					damage * GameManager.Instance.landMineEffectiveness * GameManager.Instance.bulletBonusDamagePerc, 
					true, 
					1 << 10);
				Destroy(gameObject);
			}
		}
	}

	void OnTriggerEnter2D() {
		triggered = true;
	}
}
